﻿<div class="modal-header">
    <h3 class="modal-title">Opportunity searching window</h3>
</div>
<div class="modal-body">    
    <div id="searchArea" class="row" >
        <form class="form-horizontal" role="form" name="opportunitysearchform">
            <div class="form-group">
                <label class="control-label col-sm-2" for="OppNumber">Opportunity number: </label>
                <div class="col-sm-4">
                    <input type="text" id="OppID" class="form-control" ng-model="OppNumber" autocomplete="off" />
                </div>
                <label class="control-label col-sm-2" for="OppName">Opportunity name: </label>
                <div class="col-sm-4">
                    <input type="text" id="OppName" class="form-control" ng-model="OppName" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2" for="OppOwner">Opportunity owner: </label>
                <div class="col-sm-4">
                    <input type="text" ng-model="OppOwner"
                           placeholder="Type employee name"
                           uib-typeahead="option as option.FullName for option in getEmployees($viewValue) | limitTo:10"
                           typeahead-loading="loadingEmployees"
                           typeahead-no-results="noEmployees"
                           class="form-control">
                    <i ng-show="loadingEmployees" class="glyphicon glyphicon-refresh"></i>
                    <div ng-show="noEmployees">
                        <i class="glyphicon glyphicon-remove"></i> No Results Found
                    </div>                   
                </div>
                <label class="control-label col-sm-2" for="sfdcAccount">SFDC Account Name</label>
                <div class="col-sm-4">
                    <!--modelValue as display for iterationItem in list -->
                    <input type="text" ng-model="selectedAccount"
                           placeholder="Type account name"
                           uib-typeahead="option as option.AccountName for option in getAccounts($viewValue) | limitTo:10"
                           typeahead-loading="loadingAccounts"
                           typeahead-no-results="noResults"
                           class="form-control">
                    <i ng-show="loadingAccounts" class="glyphicon glyphicon-refresh"></i>
                    <div ng-show="noResults">
                        <i class="glyphicon glyphicon-remove"></i> No Results Found
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2" for="topDivisionSelect">Top division:</label>
                <div class="col-sm-4">
                    <select name="topDivisionSelect" id="topDivisionSelect" class="form-control"
                            ng-options="option.TopDivisionName for option in topDivisions track by option.TopDivisionName"
                            ng-model="topDivisions.selectedOption">
                        <option value="">-- Select top division --</option>
                    </select>
                </div>               
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10 text-right">
                    <button type="submit" ng-click="search(opportunitysearchform)" class="btn btn-add">Search</button>
                </div>
            </div>
        </form>
    </div>  

    <div id="searchResultsArea" class="row" ng-if="searchResults.length>0">
        <table st-table="displaySearchResults" st-safe-src="searchResults" class="table contractstable">
            <thead>
                <tr>
                    <th></th>
                    <th>Opp. Number</th>
                    <th>Opp. Name</th>
                    <th>Top Division</th>
                    <th>Opp. Amount</th>
                    <th>Opp. Owner</th>
                    <th>Opp. Stage</th>                  
                    <th>Opp. Close Date</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="row in displaySearchResults" ng-class="{'st-selected': selectedOpp==row.OppNumber}">
                    <td cs-select="row">
                        <input type="radio" name="selectedOpp" ng-click="setSelectedOpp(row.OppNumber)" value="row.OppNumber" ng-checked="selectedOpp==row.OppNumber">
                    </td>
                    <td>{{ row.OppNumber }}</td>
                    <td>{{ row.OppName }}</td>
                    <td>{{ row.TopDivision }}</td>
                    <td>{{ getters.Amount(row) | number:2 }}</td>
                    <td>{{ row.Owner }}</td>
                    <td>{{ row.Stage }}</td>                   
                    <td>{{ getters.CloseDate(row) |date:"dd MMM yyyy" }}</td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="9" class="text-center">
                        <div st-items-by-page="10" st-pagination="" st-template="templates/stPagination.html"></div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
    
    <div id="message" ng-if="showError || showWarning" ng-class="{'alert-danger': showError, 'alert-warning': showWarning}" class="alert alert-dismissable">
        {{message}}
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-success" type="button" ng-click="ok()">OK</button>
    <button class="btn btn-default" type="button" ng-click="cancel()">Cancel</button>
</div>


